package com.example.demo.service.observe;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class EmailService implements ApplicationListener<UserRegisterEvent> {

    @Async
    @Override
    public void onApplicationEvent(UserRegisterEvent event) {
        log.info("当前线程为：" + Thread.currentThread().getId());
        log.info("[onApplicationEvent][给用户{}发送邮件]", event.getUserName());
    }
}
